<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link href="css/xixiaoming/baidulogin.css" type="text/css" rel="stylesheet" />
<style>
	#login_holder_1 p{
	margin:17px 0;
	}
.denglu a{background-image:url("thirdparty/denglu_icon5_all_bg.png");font-size:27px;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .renren{background-position:0px -180px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .baidu{background-position:0px -450px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .sina{background-position:0px -60px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .tencent{background-position:0px -90px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .taobao{background-position:0px -360px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .douban{background-position:0px -240px;width: 24px;height:24px;background-repeat:no-repeat;}

#productullist a{
	color:black;
}

.div1{
	letter-spacing:0em;
	padding:10px 0;
	border-style:solid;
	border-width:0px 1px;
	border-color:white #A8D9E9;
	height:20px;
	font-family:微软雅黑;
	font-size:14px;
}
.div2{
	letter-spacing:0em;
	padding:10px 0;
	border-style:solid;
	border-width:1px;
	border-color:#A8D9E9 white #A8D9E9 #A8D9E9;
	height:18px;
	font-family:微软雅黑;
	font-size:14px;
	-webkit-box-shadow:0 0 20px #A8D9E9;
	-moz-box-shadow:0 0 20px #A8D9E9;
	box-shadow:0 0 20px #A8D9E9;
}

</style>
<style>
.denglu a{background-image:url("thirdparty/denglu_icon5_all_bg.png");font-size:27px;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .renren{background-position:0px -180px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .baidu{background-position:0px -450px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .sina{background-position:0px -60px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .tencent{background-position:0px -90px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .qzone{background-position:0px -300px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .taobao{background-position:0px -360px;width: 24px;height:24px;background-repeat:no-repeat;}
.denglu .douban{background-position:0px -240px;width: 24px;height:24px;background-repeat:no-repeat;}
.shopcar{width:95px; padding-top:9px; padding-left:10px;}
.shopcar:hover{border-color:red;border-style:solid solid none solid;border-width:1px;}

</style>
<div
	style="background-color:rgb(102,102,102); border:0; width:100%; height:80px;z-index:-1;">
	<div class="head" id="head">
		<div id="webbei_logol">
			<img src="img/logo.gif" alt="" title="标识" />
		</div>
		<div class="usercando">
			<div class="usercando_dingzhi" id="usercando_dingzhi">
				<div style="width:70px;height:50px">
					<a href="/"><img
						src="img/head_custom.gif" alt="" title="首页" id="user_dingzhi"
						style="cursor:pointer" /> </a>
				</div>
				<!-- <div
					style="position:absolute; top:80px; z-index:1; left:0; display:none"
					id="test">
					<ul style="padding: 0px;margin: 0px;" id="productUL"></ul>
				</div> -->
			</div>
			<div class="usercando_share">
				<a href="showHomePage.action" target="_blank"><img
					src="img/head_share.gif" alt="" title="分享" id="user_share" /> </a>
				<!-- <div style="position:absolute; top:50px; left:-100px;">
					<ul>
					</ul>
				</div> -->
			</div>
		</div>
		<div class="search" id="search">
			<div class="something_else_up">

				<div
					style="width:130px; float:left; padding-top:2px; padding-left: 10px;">
					<!-- JiaThis Button BEGIN -->
					<div class="jiathis_style_24x24">
						<a class="jiathis_button_tsina"></a>
						<a class="jiathis_button_tqq"></a>
						<a class="jiathis_button_cqq"></a>
						<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
					</div>
					<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
					<!-- JiaThis Button END -->
				</div>
			</div>
			<script type="text/javascript">
				function refreshShopcar(){
					var $goods=$("#goodslist");
					$goods.empty();
					if($('#shopcarcount').html()!=0){
						$.getJSON("showShopCar_ajax",{dd:new Date().getTime()},function(data){
							$.each(data.cuslist,function(index,v){
								$tr=$("<tr></tr>").appendTo($goods);
								$td1=$("<td width='auto'></td>").appendTo($tr);//商品
								$td2=$("<td width='50%' align='center' STYLE='vertical-align:middle'></td>").appendTo($tr);//价格
								$td3=$("<td width='20%' align='center' STYLE='vertical-align:middle'></td>").appendTo($tr);//删除
								$("<img src='"+v.customPic+"' style='width:60px;height:auto;'/>").appendTo($td1);
								$("<font>"+v.customPrice+"元</font>").appendTo($td2);
								$("<a href='javascript:deleteShopCarSession("+v.customId+");'>删除</a>").appendTo($td3);
							});
						});
					}else{
						$("#gouwuche font:eq(0)").html("购物车空空的");
					}
				}
				function deleteShopCarSession(id){
					$.ajax({
						url:"sessionControl_deleteShopCar.action",
						data:{customId:id},
						type:"post",
						success:function(data){
							$("#shopcarcount").html(data.shopcarsize);
							refreshShopcar();
						}
					});
				}
				function showShopCar(){
					if($("#shopcarcount").html()=='0'){
						alert("购物车中没有商品");
					}else{
						window.location.href="showShopCar.action";
					}
				}
				/* function checkemail() {
					if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
							.test(document.getElementById("email").value))) {
						$("#email").val("");
					}
				} */
				function getCookie(c_name) {
					if (document.cookie.length > 0) {
						c_start = document.cookie.indexOf(c_name + "=");
						if (c_start != -1) {
							c_start = c_start + c_name.length + 1;
							c_end = document.cookie.indexOf(";", c_start);
							if (c_end == -1)
								c_end = document.cookie.length;
							return unescape(document.cookie.substring(c_start,c_end));
						}
					}
					//alert("获取不到cookies");
					return "";
				}
				function deleteSessionAndCookies() {
					$(".loginandresign").show();
					logoutSuccess();
					//删除掉Cookies(OK)
					var usernmae=getCookie("wangbeiCookieUsername");
					if (usernmae) {
						var expiredays = 365;//Cookie保存365天
						var exdate = new Date();
						exdate.setDate(exdate.getDate()+ expiredays);
						document.cookie = "wangbeiCookieUsername="+ ""+ ((expiredays == null) ? "": "; expires="+ exdate.toGMTString());
					}
					$.ajax({
						url : "sessionControl_deleUserSession.action",
						type : "post"
					});
				}
				function loginSuccess(name){
					$("#showusersNamefont1").html(name);
					$("#showusersNamefont").attr("href","ShowMyCustom");
					$("#showusersNamea1").html("退出");
					$("#showusersNamea").attr("href","javascript:deleteSessionAndCookies();");
					setTimeout(function(){
						$("#showusersNamea").attr("target","_top");
					},100);
				}
				function logoutSuccess(){
					$("#showusersNamefont1").html("");
					$("#showusersNamefont").attr("href","");
					$("#showusersNamea1").html("");
					$("#showusersNamea").attr("href","");
				}
				function searchWebbei(){
					var something=$.trim($("#searchsomething").val());
					if(something==''||something==null||something=='null'){
						alert("请输入查询内容");
					}else{
						$.getJSON("searchWebbei",{something:something},function(d){
							window.location.href="showHomePage?productid="+d.productid;
						});
					}
				}
				function checkLogin() {
					var email = document.getElementById("pass_login_username_0").value;
					var pwd = document.getElementById("pass_login_password_0").value;
					var curr=$("#login_tab_1").attr("class")=="curr";
					var mail=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
					var mobile=/^1[3|4|5|8][0-9]\d{4,8}$/;
					if (pwd != '' && pwd != null) {
						if ((mail.test(email)&&curr)||(mobile.test(email)&&!curr)) {
							$.getJSON("checkLoginAtTop.action",{
								email : email,
								password : pwd
							},
							function(data) {
								if (data.customerCount == 1) {
									if (document.getElementById("pass_login_rem_0").checked) {
										//增加一个Cookie(OK)
										var expiredays = 365;//Cookie保存365天
										var exdate = new Date();
										exdate.setDate(exdate.getDate()+ expiredays);
										document.cookie = "wangbeiCookieUsername="+ escape(data.username)+ ((expiredays == null) ? "": "; expires="+ exdate.toGMTString());
									}
									$(".loginandresign").hide();
									loginSuccess(data.username);
									$("#login").dialog("close");
									if($("#logincheck").size()>0){
										location.reload();
									}
								} else {
									if(curr) alert('邮箱和密码不匹配'); else alert('手机和密码不匹配');
								}
							});
						} else {
							if(curr) alert('邮箱格式错误'); else alert('手机格式错误');
						}
					} else {
						alert('密码不能为空');
					}
				}
				$(document).keydown(function(event){
					if((event.keyCode==13&&$(document.activeElement).attr("id")=="pwd")||(event.keyCode==13&&$(document.activeElement).attr("id")=="email")){
						checkLoginAtTop();
					}
					if((event.keyCode==13&&$(document.activeElement).attr("id")=="pass_login_username_0")||(event.keyCode==13&&$(document.activeElement).attr("id")=="pass_login_password_0")){
						checkLogin();
					}
					if((event.keyCode==13&&$(document.activeElement).attr("id")=="searchsomething")||(event.keyCode==13&&$(document.activeElement).attr("id")=="searchsomething")){
						searchWebbei();
					}
				});
				$(document).ready(function() {
					$("#login").dialog({
						autoOpen : false,
						module : true,
						//hide : "fadeout",
						modal : true,
						title : "登录",
						width:485,
						height:420,
						position:[(window.innerWidth-400)/2,(window.innerHeight-300)/2],
						resizable:false
					});
					var ss = '<%=request.getSession().getAttribute("username")%>';
					if (ss == 'null' || ss == "") {
						//alert('session为空');
						username = getCookie("wangbeiCookieUsername");
						//alert("结束获取COOKIRS");
						if (username != null && username != "") {
							//alert('cookies存在：'+username);
							$.ajax({
								url : "addUserSession.action",
								data : {
									username : username
								},
								type : "post"
							});
							$(".loginandresign").hide();
							loginSuccess(username);
						} else {
							//alert('cookies为空');
						}
					} else {
						//alert('session存在：'+ss);
						$(".loginandresign").hide();
						loginSuccess(ss);
					}
					var s1 = '<%=request.getSession().getAttribute("countshopcar")%>';
					if (s1 == 'null' || s1 == "") {
						$("#shopcarcount").html(0);
					} else {
						$("#shopcarcount").html(s1);
					}

					$.getJSON("getProductAction.action",function(data){
						var a=document.getElementById("productullist");
						$.each(data.productList,function(index,value){
							var li=document.createElement("div");
							li.setAttribute("class", "div1");
							$.each(value.plist,function(i,v){
								var font=document.createElement("a");
								font.innerHTML=v.productName;
								li.appendChild(font);
								font.setAttribute("onmouseover","$(this).css('cursor','pointer');$('#productullist a').css('text-decoration','');$(this).css('text-decoration','underline');");
								font.setAttribute("onclick","showProductPic("+v.productId+");$('#productullist a').css('color','black');$(this).css('color','red');$(this).css('text-decoration','');$('#productullist>div').attr('class','div1');$(this).parent().attr('class','div2');");
								if(i!=value.psize-1) li.innerHTML+="，";
							});
							a.appendChild(li);
						});
					});
							if (typeof (HTMLElement) != "undefined") {
			             		HTMLElement.prototype.contains = function (obj) {
				                 	while (obj != null && typeof (obj.tagName) != "undefined") {
					                     if (obj == this)
					                         return true;
					                     obj = obj.parentNode;
					                 }
					                 return false;
				             	};
				         	}
							$("#pictureDetail").mouseout(function () {
								var event = arguments[0]||window.event;
					            if(!this.contains(event.toElement || event.relatedTarget)){
									$("#pictureDetail").slideUp('slow');
								}
					        });
							/* $("#login_level").mouseleave(function () {
						        $(this).fadeOut("normal");
						    }); */
						    /* $("#login_btn").click(function () {
						        $("#login").dialog("open");
                                denglu();
                                $("#denglu").html($("#hiddenDenglu").html());
                                $("#hiddenDenglu").html("");
						    }); */
						    $("#login_level").mouseleave(function () {
						        $(this).hide("slow");
						    });
						  $("#user_dingzhi").mouseover(function () {
						        $("#productList").show();
						        $("#productullist").show();
						    });
						    $("#productList").mouseleave(function () {
						        $("#productullist").hide();
						        $("#productList").hide();
						    });
						});

						function showProductPic(a){
							$.getJSON("getProductPicByProductId.action",{
								productid:a,
								d:new Date().getTime()
							},function(data){
								var pic=document.getElementById("pictureDetail");
								$("#pictureDetail").html("");
								$.each(data.bgpiclist,function(index,v){
									var img=document.createElement("img");
									img.setAttribute("style", "width:189px;height:144px;margin:5px;");
									img.setAttribute("src", v.picUrl);
									img.setAttribute("onclick", "changeBgPic('"+v.url_bak+"','"+v.picUrl+"')");
									pic.appendChild(img);
								});
							});
							$("#pictureDetail").show("slow");
						}
						function changeBgPic(a,b){
							if($("#xxoo").length>0){//分享重定制页面
								document.getElementById("bg").style.background="url("+b+") no-repeat center bottom";
								$.getJSON("getProductSizeByBgPic.action",{//修改字体的大小
									bgpic:b
								},function(data){
									$("#fontsize").val(data.size);
								});
							}else if($("#xxoo1").length>0){//定制首页
								$.post("getAllStyle",{
										"url":a
								},function(data){
									var html = "";
									$.each(data.urls,function(index,value){
										html = html + "<li style='float:left; list-style:none; margin-right:10px;'>"+
									    	"<img width=107 height=107 src="+value+" onclick=changeBg('"+value+"')></li>";
									});
									$(".prev").css("display","none");
									$(".next").css("display","none");
									$(".bx_container:eq(1)").css("width","1000px");
									$(".bx_container:eq(1)").css("margin-left","-180px");
									$("#example1").css("left","0px");
									$("#example1").css("width","1000px");
									$("#example1").html(html);
								});
								$.getJSON("getProductSizeByBgPic.action",{bgpic:a},
									function(data){
										$("#fontsize").val(data.size);
								});
							}else{
								window.location.href="showProduct?bgPic="+a;
							}
						}

function winOpen (strURL,strName,width,height)
{
    theWindow = window.open (strURL,strName,"width="+width+" height="+height+" scrollbars=yes left="+(1024-width)/2+" top="+(768-height)/2);
    if (theWindow.opener == null) theWindow.opener = window;
    if (window.focus) theWindow.focus();
}
			</script>
			<div>
				<div style="float:left;">
					<input type="text" style="height:24px;" id="searchsomething" />
				</div>
				<div style="float:left;">
					<a href="javascript:searchWebbei()"><img src="img/head_search_bt.gif"
						style="height:25px;" alt="" title="查询" /> </a>
				</div>
			</div>
		</div>
		<div class="something_else">
			<div class="something_else_down">

				<div class="loginandresign" style="padding-top:15px;">
					<a href="javascript:" onclick="$('#login').dialog('open');denglu();$('#denglu').html($('#hiddenDenglu').html());$('#hiddenDenglu').html('');">
						<font id="login_btn" style="float:left; cursor:pointer; font-size:13px;">登录|</font>
					</a>
					<a href="register.jsp">
						<font id="resign_btn" style="float:left; cursor:pointer;font-size:13px;">注册</font>
					</a>
				</div>
				<div style="width:100%; height:35px; padding-top:10px;text-align:left;font-size:14;font-family:'微软雅黑';"
					id="showusersName">
					<a id="showusersNamefont"><font id="showusersNamefont1" style="font-size:15px;color:#00C"></font>
					</a> <a href="" target="_top" id="showusersNamea"><font
						id="showusersNamea1" style="font-size:10px;"></font>
					</a>
				</div>
				<div class="shopcar" onmouseover="refreshShopcar();$('#gouwuche').show();">
					<div style="float:left;">
						<img src="img/head_cart.gif" alt="" title="" />
					</div>
					<div style="height:20px; padding-top:5px;font-size:13px;font-family:微软雅黑;cursor:pointer;" onclick="showShopCar()">
						&nbsp;购物车<font id="shopcarcount" color=red>0</font>件
					</div>
				</div>
				<div id="gouwuche"
				onmouseout="var event = arguments[0]||window.event;if(!this.contains(event.toElement || event.relatedTarget)){$(this).hide();}"
				style="position:relative;margin-top:-4px;width:200px;height:auto;display:none;background-color:#EBEBEB;z-index:10000;border-color:red;border-style:none solid solid solid;border-width:1px;">
					<div style="width:100%;height:auto;margin-top:4px;">
						<table id="goodslist"></table>
					</div>
					<div><font style="font-weight:bold;color:red;"></font></div>
				</div>
			</div>
		</div>
	</div>
	<div id="productList" style="z-index:20000000000;background-color:white;display:none;position:absolute;top:80px;left:211px;clear:both;width:860px;height:auto;">
		<div style="overflow:auto;text-align:center;height:100%;list-style-type:none;float:left;z-index:1001;width:278px;left:170px;border-bottom:1px solid #A8D9E9;" id="productullist"></div>
		<div id="pictureDetail" style="text-align:center;display:none;z-index:1000000001;background-color:white;width:580px;height:100%;float:right;"></div>
	</div>
	<!-- 登录弹出层 -->
	<div id="login" style="display:none;background-color:#fff;overflow:hidden;">
		<ul class="login_tab" style="padding:0px;list-style:none outside none;">
			<li class="curr" id="login_tab_1"
				onclick="$('#login_tab_1').attr('class','curr');$('#login_tab_2').attr('class','');$('#pass_login_label_username_0').html('&#12288;邮箱');">邮箱登录</li>
			<li id="login_tab_2" class=""
				onclick="$('#login_tab_2').attr('class','curr');$('#login_tab_1').attr('class','');$('#pass_login_label_username_0').html('手机号');">手机登录</li>
		</ul>
		<div id="login_holder">
			<div id="login_holder_1" style="display: block;">
				<p id="pass_login_p_username_0" style="height:47px;">
					<label for="pass_login_username_0" id="pass_login_label_username_0" class="pass_login_label pass_login_label_username">&#12288;邮箱</label>
					<input type="text" name="username" id="pass_login_username_0" class="pass_login_input pass_login_input_username" />
				</p>
				<p id="pass_login_p_password_0" style="height:47px;">
					<label for="pass_login_password_0" id="pass_login_label_password_0" class="pass_login_label pass_login_label_password">&#12288;密码</label>
					<input type="password" name="password" id="pass_login_password_0" class="pass_login_input pass_login_input_password" />
				</p>
				<p id="pass_login_p_rem_0" style="font-size:13px;margin:-9px 0 0 -176px;">
					<input type="checkbox" checked="checked" name="mem_pass" id="pass_login_rem_0" class="pass_login_input pass_login_input_rem" />
					<label for="pass_login_rem_0" id="pass_login_label_rem_0" class="pass_login_label pass_login_label_rem">记住我的登录状态</label>
				</p>
				<p id="pass_login_p_btn_0" style="height:51px;margin:20px 0 0 -121px;">
					<input onclick="checkLogin();" type="button" value="登录" id="pass_login_input_submit_0" class="pass_login_input pass_login_input_submit" />
					<a id="pass_login_a_fgtpwd_0" class="pass_login_a_fgtpwd" href="" target="_blank">忘记密码？</a>
				</p>
			</div>
		</div>
		<div class="reg_line"></div>
		<p class="reg_holder">
			还没有网贝帐号？
			<a id="reg_btn" target="_blank" href="register.jsp">立即注册</a>
		</p>
		<p id="denglu" class="denglu">第三方登录：

		<a class="tencent" href="http://open.denglu.cc/transfer/tencent?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="腾讯微博"/></a>
		<a class="qzone" href="http://open.denglu.cc/transfer/qzone?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="腾讯QQ"/></a>
		<a class="sina" href="http://open.denglu.cc/transfer/sina?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="新浪微博"/></a>
		<a class="renren" href="http://open.denglu.cc/transfer/renren?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="人人网"/></a>
		<a class="taobao" href="http://open.denglu.cc/transfer/taobao?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="淘宝网"/></a>
		<a class="douban" href="http://open.denglu.cc/transfer/douban?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="豆瓣网"/></a>
		<a class="baidu" href="http://open.denglu.cc/transfer/baidu?appid=52643&redirect_uri=http%3A%2F%2Fwww.webbei.com">
		<img src="images/png/400300.png" height="24" width="24" title="百度连接"/></a>
			</p>
	</div>
</div>